package main

import (
	"MaterialIdentification/svc"
	"github.com/gin-contrib/cors"
	"net/http"
)

type Resp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func NewResp(code int, msg string) Resp {
	return Resp{
		Code: code,
		Msg:  msg,
	}
}

type RespData[T any] struct {
	Resp
	Data T `json:"data"`
}

func NewRespData[T any](msg string, data T) RespData[T] {
	return RespData[T]{
		Resp: Resp{
			Msg: msg,
		},
		Data: data,
	}
}

func main() {
	svc.GinServer.StaticFile("/", "./dist/dist/index.html")
	svc.GinServer.StaticFS("/assets", http.Dir("./dist/dist/assets"))
	svc.GinServer.Use(cors.Default())
	Router(svc.GinServer)
	svc.GinServer.Run(":8888")
}
